| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 9 | describe('Plugin', function () { |
||
| 10 | describe('#installer', function () { |
||
| 11 | it('"Plugin.install" Should be a function', function () { |
||
| 12 | should(Plugin.install).be.a.Function() |
||
| 13 | }) |
||
| 14 | }) |
||
| 15 | |||
| 16 | describe('#Installed', function () { |
||
| 17 | it('Plugin Should be installed', function () { |
||
| 18 | const Vue = require('vue').default |
||
| 19 | Vue.use(Plugin) |
||
| 20 | |||
| 21 | assert.property(Vue, 'dialog') |
||
| 22 | }) |
||
| 23 | }) |
||
| 24 | |||
| 25 | describe('#Available', function () { |
||
| 26 | it('"$dialog" Should be a available on the created, mounted hooks', function () { |
||
| 27 | const Vue = require('vue').default |
||
| 28 | Vue.use(Plugin) |
||
| 29 | |||
| 30 | new Vue({ |
||
| 31 | created(){ |
||
| 32 | assert.property(this, '$dialog') |
||
| 33 | }, |
||
| 34 | mounted(){ |
||
| 35 | assert.property(this, '$dialog') |
||
| 36 | }, |
||
| 37 | render(h){ |
||
| 38 | return h('p', {id: 'test'}, 'test') |
||
| 39 | } |
||
| 40 | }).$mount() |
||
| 41 | }) |
||
| 42 | |||
| 43 | it('"$dialog" Should be a available in component methods', function () { |
||
| 44 | const Vue = require('vue').default |
||
| 45 | Vue.use(Plugin) |
||
| 46 | |||
| 47 | let vm = new Vue({ |
||
| 48 | methods: { |
||
| 49 | check(){ |
||
| 50 | assert.property(this, '$dialog') |
||
| 51 | } |
||
| 52 | }, |
||
| 53 | render(h){ |
||
| 54 | return h('p', {id: 'test'}, 'test') |
||
| 55 | } |
||
| 56 | }).$mount() |
||
| 57 | |||
| 58 | vm.check() |
||
| 59 | }) |
||
| 60 | }) |
||
| 61 | |||
| 62 | }) |